package com.iotteam.androidbase.moudules.sensor_setting.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.iotteam.androidbase.R;
import com.iotteam.androidbase.base.ToolbarActivity;
import com.iotteam.androidbase.moudules.sensor_setting.presenter.ISensorSettingPresenter;
import com.iotteam.androidbase.moudules.sensor_setting.presenter.SensorSettingPresenter;

/**
 * Created by lidechen on 6/25/17.
 */

public class SensorSettingActivity extends ToolbarActivity implements ISensorSettingView{

    private ISensorSettingPresenter mPresenter;

    private EditText mMsg1Edit;
    private EditText mMsg2Edit;
    private EditText mMsg3Edit;

    private Button mSendBtn;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_sensor_setting;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mMsg1Edit = (EditText) findViewById(R.id.edit_text_msg1);
        mMsg2Edit = (EditText) findViewById(R.id.edit_text_msg2);
        mMsg3Edit = (EditText) findViewById(R.id.edit_text_msg3);

        mSendBtn = (Button) findViewById(R.id.btn_send);

        mPresenter = new SensorSettingPresenter(SensorSettingActivity.this);

        mSendBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPresenter.sendMessageToSensor();
            }
        });
    }

    public static void launch(Context context) {
        context.startActivity(new Intent(context, SensorSettingActivity.class));
    }

    @Override
    public String getMessage1() {
        return mMsg1Edit.getText().toString().trim();
    }

    @Override
    public String getMessage2() {
        return mMsg2Edit.getText().toString().trim();
    }

    @Override
    public String getMessage3() {
        return mMsg3Edit.getText().toString().trim();
    }

    @Override
    public void showLoading() {
        mWaitDialog.show();
    }

    @Override
    public void dismissLoading() {
        mWaitDialog.dismiss();
    }

    @Override
    public void setLoadingString(String str) {
        mWaitDialog.setContent(str);
    }
}
